home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / addflo / data1.cab / Program_Executable_Files / AddFlow / Samples / Demo / Diagram.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-05-06  |  5.6 KB  |  181 lines

  1. VERSION 4.00
  2. Begin VB.Form frmDiagram 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    Caption         =   "Example 3: Diagrams"
  6.    ClientHeight    =   3825
  7.    ClientLeft      =   405
  8.    ClientTop       =   2070
  9.    ClientWidth     =   5445
  10.    FillColor       =   &H0000FFFF&
  11.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  12.       Name            =   "MS Sans Serif"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    Height          =   4230
  22.    Left            =   345
  23.    LinkTopic       =   "Form3"
  24.    MDIChild        =   -1  'True
  25.    ScaleHeight     =   3825
  26.    ScaleWidth      =   5445
  27.    Tag             =   "3"
  28.    Top             =   1725
  29.    Width           =   5565
  30.    Begin AddFlowLib.AddFlow AddFlow1 
  31.       Height          =   3015
  32.       Left            =   600
  33.       TabIndex        =   0
  34.       Top             =   600
  35.       Width           =   4245
  36.       _Version        =   65536
  37.       _ExtentX        =   7488
  38.       _ExtentY        =   5318
  39.       _StockProps     =   101
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  41.          Name            =   "Arial"
  42.          Size            =   8.25
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       BorderStyle     =   1
  50.       ScrollBars      =   3
  51.       Shape           =   0
  52.       LinkStyle       =   0
  53.       Alignment       =   7
  54.       AutoSize        =   0
  55.       ArrowDst        =   3
  56.       ArrowOrg        =   0
  57.       DrawStyle       =   0
  58.       DrawWidth       =   1,4013e-45
  59.       ReadOnly        =   0   'False
  60.       MultiSel        =   -1  'True
  61.       CanDrawNode     =   -1  'True
  62.       CanDrawLink     =   -1  'True
  63.       CanMoveNode     =   -1  'True
  64.       CanSizeNode     =   -1  'True
  65.       CanStretchLink  =   -1  'True
  66.       CanMultiLink    =   -1  'True
  67.       Transparent     =   0   'False
  68.       ShowGrid        =   0   'False
  69.       Hidden          =   0   'False
  70.       Rigid           =   0   'False
  71.       DisplayHandles  =   -1  'True
  72.       AutoScroll      =   -1  'True
  73.       xGrid           =   7,00649e-45
  74.       yGrid           =   7,00649e-45
  75.       xZoom           =   100
  76.       yZoom           =   100
  77.       FillColor       =   16777215
  78.       DrawColor       =   0
  79.       ForeColor       =   0
  80.       BackPicture     =   "Diagram.frx":0000
  81.    End
  82. Attribute VB_Name = "frmDiagram"
  83. Attribute VB_Creatable = False
  84. Attribute VB_Exposed = False
  85. Option Explicit
  86. Dim n%, flag%
  87. Dim X0&, Y0&
  88. Private Sub Form_Activate()
  89.   frmMain.ActivateForm
  90. End Sub
  91. Private Sub Form_Deactivate()
  92.   frmMain.DeactivateForm
  93. End Sub
  94. Private Sub Form_Load()
  95.   frmMain.ShowExample(2).Enabled = False
  96.   n = 1
  97.   flag = False
  98.   Dim nodx As afNode, lnkx As afLink
  99.   With AddFlow1
  100.     .Left = 0
  101.     .Top = 0
  102.     ' Just to accelerate display (Don't forget to reset it at the end)
  103.     .Repaint = False
  104.     .DrawColor = RGB(255, 0, 0)
  105.     .FillColor = &HC0FFFF
  106.     ' Create nodes
  107.     Set nodx = .Nodes.Add(600, 200, 500, 500)
  108.     nodx.Text = n
  109.     n = n + 1
  110.     Set nodx = .Nodes.Add(2100, 200, 500, 500)
  111.     nodx.Text = n
  112.     n = n + 1
  113.     Set nodx = .Nodes.Add(1600, 1700, 500, 500)
  114.     nodx.Text = n
  115.     n = n + 1
  116.     Set nodx = .Nodes.Add(100, 1700, 500, 500)
  117.     nodx.Text = n
  118.     n = n + 1
  119.     ' Create links
  120.     Set lnkx = .Nodes(1).OutLinks.Add(.Nodes(2))
  121.     Set lnkx = .Nodes(2).OutLinks.Add(.Nodes(3))
  122.     Set lnkx = .Nodes(3).OutLinks.Add(.Nodes(4))
  123.     Set lnkx = .Nodes(1).OutLinks.Add(.Nodes(4))
  124.     Set lnkx = .Nodes(1).OutLinks.Add(.Nodes(3))
  125.     .Repaint = True
  126.   End With
  127. End Sub
  128. Private Sub Form_Resize()
  129.   If WindowState <> 1 And ScaleHeight <> 0 Then
  130.     AddFlow1.Height = ScaleHeight
  131.     AddFlow1.Width = ScaleWidth
  132.   End If
  133. End Sub
  134. Private Sub Form_Unload(Cancel As Integer)
  135.   frmMain.ShowExample(2).Enabled = True
  136. End Sub
  137. Private Sub AddFlow1_KeyDown(KeyCode As Integer, Shift As Integer)
  138.   Const KEY_DELETE = &H2E
  139.   If KeyCode = KEY_DELETE Then
  140.     AddFlow1.DeleteSel
  141.   End If
  142. End Sub
  143. Private Sub AddFlow1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  144.   Me.SetFocus
  145.   If AddFlow1.PointedArea = 5 Then
  146.     flag = True
  147.     X0 = X
  148.     Y0 = Y
  149.   End If
  150. End Sub
  151. Private Sub AddFlow1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  152.   Dim Xabs As Single, Yabs As Single
  153.   Dim Org As afNode, Dst As afNode, link As afLink
  154.   Dim Action As Long
  155.   Action = AddFlow1.LastUserAction()
  156.   If Action = 1 Then
  157.     AddFlow1.SelectedNode.Text = n
  158.     n = n + 1
  159.   End If
  160.   If flag = True Then
  161.     flag = False
  162.     ' If a link has been created, don't create a new one ==> exit
  163.     If Action = 2 Then Exit Sub
  164.     If (Abs(X - X0) < 300 And Abs(Y - Y0) < 300) Then Exit Sub
  165.     ' Origin node of next created link
  166.     Set Org = AddFlow1.SelectedNode
  167.     ' No current item
  168.     Set AddFlow1.SelectedNode = Nothing
  169.     Xabs = X + AddFlow1.xScroll
  170.     Yabs = Y + AddFlow1.yScroll
  171.     ' Create destination node
  172.     Set Dst = AddFlow1.Nodes.Add(Xabs - 250, Yabs - 250, 500, 500)
  173.     If Not (Dst Is Nothing) Then
  174.       Dst.Text = Str(n)
  175.       n = n + 1
  176.       ' Create link
  177.       Set link = Org.OutLinks.Add(Dst)
  178.     End If
  179.   End If
  180. End Sub
  181.